package com.edu.service;

import com.edu.bean.StudentScore;
import com.edu.bean.SubjectInfo;
import com.edu.dao.StudentScoreDao;
import com.edu.dao.SubjectInfoDao;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

public class UserScoreService {
    private StudentScoreDao studentScoreDao = new StudentScoreDao();
    private SubjectInfoDao subjectInfoDao = new SubjectInfoDao();

    /**
     * 获取用户的成绩列表（分页）
     */
    public Map<String, Object> userListScores(Integer userId, Integer subjectId, int page, int limit) {
        Map<String, Object> result = new HashMap<>();

        int start = (page - 1) * limit;
        List<StudentScore> list = studentScoreDao.findByStudentIdAndPage(userId, subjectId, start, limit);
        int total = studentScoreDao.findTotalCountByStudentId(userId, subjectId);

        result.put("list", list);
        result.put("total", total);
        return result;
    }

    /**
     * 获取所有学科列表
     */
    public List<SubjectInfo> userListSubjects() {
        return subjectInfoDao.findAll();
    }
}